#include "PrecompiledHeader.h"
#include "SpotLight.h"

/*--------------------------------------------------------------------------*/

SpotLight::SpotLight(const NodeCreation& nc) :
	ILightSourceObject(nc)
{
	AssertModule(g_Material);

	RenderTaskDesc desc;
	desc.m_material = g_Material->GetMaterial("mat_spotlight");
	desc.m_argument = 0;
	desc.m_flags = ERenderTaskFlag::LightSource | ERenderTaskFlag::Transparent;
	desc.m_priority = 0;
	desc.m_object = this;

	this->AddRenderTask(desc);
}

/*--------------------------------------------------------------------------*/

SpotLight::~SpotLight()
{

}

/*--------------------------------------------------------------------------*/

void SpotLight::DrawLightVolume()
{
#ifdef VL_RENDER_STATISTICS
	g_Hud->GetStatisticsManager()->IncrementStatistic("SpotLight");
#endif
	ROpenGL::CullFaceMode(GL_FRONT);
// 	OpenGL::RawBegin(GL_QUADS);
// 	OpenGL::RawDrawRectangle(glm::vec3(1.0f, -1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, 1.0f, -1.0f),
// 	                         glm::vec3(1.0f, 1.0f, -1.0f));
//
// 	OpenGL::RawDrawRectangle(glm::vec3(1.0f, 1.0f, 1.0f),
// 	                         glm::vec3(-1.0f, 1.0f, 1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, 1.0f),
// 	                         glm::vec3(1.0f, -1.0f, 1.0f));
//
// 	OpenGL::RawDrawRectangle(glm::vec3(-1.0f, 1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, 1.0f),
// 	                         glm::vec3(-1.0f, 1.0f, 1.0f));
//
// 	OpenGL::RawDrawRectangle(glm::vec3(1.0f, 1.0f, 1.0f),
// 	                         glm::vec3(1.0f, -1.0f, 1.0f),
// 	                         glm::vec3(1.0f, -1.0f, -1.0f),
// 	                         glm::vec3(1.0f, 1.0f, -1.0f));
//
// 	OpenGL::RawDrawRectangle(glm::vec3(1.0f, -1.0f, 1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, 1.0f),
// 	                         glm::vec3(-1.0f, -1.0f, -1.0f),
// 	                         glm::vec3(1.0f, -1.0f, -1.0f));
//
// 	OpenGL::RawDrawRectangle(glm::vec3(1.0f, 1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, 1.0f, -1.0f),
// 	                         glm::vec3(-1.0f, 1.0f, 1.0f),
// 	                         glm::vec3(1.0f, 1.0f, 1.0f));
// 	OpenGL::RawEnd();
}

/*--------------------------------------------------------------------------*/

const glm::vec3& SpotLight::GetDirection() const
{
	return this->m_direction;
}

/*--------------------------------------------------------------------------*/

void SpotLight::SetDirection(const glm::vec3& dir)
{
	this->m_direction = dir;
}

/*--------------------------------------------------------------------------*/

float SpotLight::GetAngleCos() const
{
	return this->m_angleCos;
}

/*--------------------------------------------------------------------------*/

void SpotLight::SetAngleCos(float angle)
{
	this->m_angleCos = angle;
}

/*--------------------------------------------------------------------------*/

void SpotLight::OnPreRender(const uint i, ERenderQuality::Type quality)
{
	//g_Material->SetLightningUBO(&this->GetRelativePosition(), &this->GetAmbient(), &this->GetSpecular(), &this->GetDiffuse(), &this->GetRadius(), &this->m_angleCos, &this->m_direction);
}

/*--------------------------------------------------------------------------*/